Edit exported word document

I wrote a dxl script which will automate the Export to word. Now I want dxl script to edit the existing instance of word to update the exported document to 'web layout' and 'auto fit to window'.

One option would be to save the exported document and open the document for editing further.

DB theDiag = null
 
void connectToWord() 
{
    checkPlatform "Microsoft Word"
 
        app = connectToApp(cObjWordApplication, "Word")
        if (null app) 
        {
                ack "Falied to create word application"
                halt
        }
    .....
        //what is the ole to change to web layout
 
} 
 
// Now override block and show, to only do realize
void show  (DB x) { realize x; theDiag = x }
void block (DB x) { realize x; theDiag = x }
 
if (null current Module) {
        print "Kindly select DOORs module for the export."
        halt
}
 
#include <standard/export/office/word.dxl> 
// Dialog optins of itfui2.inc and word.dxl can be overwritten
set(exportLayoutChoice, layoutTypeTable)                   // layout selected as table          
 
//Invoke Export to Word dialog
doExport theDiag
 
// destroy the dialog
if (!null theDiag) destroy theDiag
 
connectToWord()

DXLScripter - Fri Jan 11 08:27:34 EST 2013

Re: Edit exported word document
DXLScripter - Fri Jan 11 09:30:49 EST 2013

Here is the updated code
 

#include <C:\Program Files\Telelogic\DOORS_8.3\lib\dxl\utils\ole.inc>
 
DB theDiag = null
 
void connectToWord() 
{
    const string cPropertyCustomDocumentProperties  = "CustomDocumentProperties"
        
        OleAutoArgs objArgBlock
        OleAutoObj objWord
        OleAutoObj objDoc
        OleAutoObj   objCustomProperties      = null
        OleAutoObj   objProperty              = null
        
        // Need OLE argument block
        objArgBlock = create
        // (Re-)attach to existing word application
        objWord = oleGetAutoObject(cObjWordApplication)
        // Get Active Document
        checkRes(oleGet (objWord, cPropertyActiveDocument, objDoc))
        // Get CustomProperties Collection
        checkRes(oleGet (objDoc, cPropertyCustomDocumentProperties, objCustomProperties))
         
        //Need Code to change to web layout
        //Need Code to auto fit to window
 
} 
 
// Now override block and show, to only do realize
void show  (DB x) { realize x; theDiag = x }
void block (DB x) { realize x; theDiag = x }
 
if (null current Module) {
        print "Kindly select DOORs module for the export."
        halt
}
 
{ 
#include <standard/export/office/word.dxl> 
// Dialog optins of itfui2.inc and word.dxl can be overwritten
set(exportLayoutChoice, layoutTypeTable)                   // layout selected as table          
 
//Invoke Export to Word dialog
doExport theDiag
 
// destroy the dialog
if (!null theDiag) destroy theDiag
}
connectToWord()

Re: Edit exported word document
Mathias Mamsch - Fri Jan 11 12:24:06 EST 2013

DXLScripter - Fri Jan 11 09:30:49 EST 2013

Here is the updated code
 

#include <C:\Program Files\Telelogic\DOORS_8.3\lib\dxl\utils\ole.inc>
 
DB theDiag = null
 
void connectToWord() 
{
    const string cPropertyCustomDocumentProperties  = "CustomDocumentProperties"
        
        OleAutoArgs objArgBlock
        OleAutoObj objWord
        OleAutoObj objDoc
        OleAutoObj   objCustomProperties      = null
        OleAutoObj   objProperty              = null
        
        // Need OLE argument block
        objArgBlock = create
        // (Re-)attach to existing word application
        objWord = oleGetAutoObject(cObjWordApplication)
        // Get Active Document
        checkRes(oleGet (objWord, cPropertyActiveDocument, objDoc))
        // Get CustomProperties Collection
        checkRes(oleGet (objDoc, cPropertyCustomDocumentProperties, objCustomProperties))
         
        //Need Code to change to web layout
        //Need Code to auto fit to window
 
} 
 
// Now override block and show, to only do realize
void show  (DB x) { realize x; theDiag = x }
void block (DB x) { realize x; theDiag = x }
 
if (null current Module) {
        print "Kindly select DOORs module for the export."
        halt
}
 
{ 
#include <standard/export/office/word.dxl> 
// Dialog optins of itfui2.inc and word.dxl can be overwritten
set(exportLayoutChoice, layoutTypeTable)                   // layout selected as table          
 
//Invoke Export to Word dialog
doExport theDiag
 
// destroy the dialog
if (!null theDiag) destroy theDiag
}
connectToWord()

Look in google for VBA code that accomplishes your goal. VBA code can be translated to DXL in a straight forward way. That is not a real DXL question, more a word automation question. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Edit exported word document
DXLScripter - Mon Jan 14 05:41:49 EST 2013

Mathias Mamsch - Fri Jan 11 12:24:06 EST 2013
Look in google for VBA code that accomplishes your goal. VBA code can be translated to DXL in a straight forward way. That is not a real DXL question, more a word automation question. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

I did try to match the VBA to dxl but unfortunately I did not get the code to Autofit to window

VBA code for AutoFit to Window is : Selection.Tables(1).AutoFitBehavior (wdAutoFitWindow)
The below is what I tried to match with dxl.
 

objArgBlock = create
    objWord = oleGetAutoObject(cObjWordApplication)
        checkRes(oleGet (objWord, cPropertyActiveDocument, objDoc))
         
        oleGet(objWord,"ActiveWindow", objWindow)
        olePut(objWindow, "View", 6)  //Code to change to web layout
        
        oleGet(objDoc, cPropertyTables, objTables)
        clear(objArgBlock)
        put(objArgBlock, 1)
        oleMethod(objTables, "Item", objArgBlock, objTable)
        olePut(objTable, "AutoFitBehavior", 2)        //Code to auto fit to window


Could you guide me on what went wrong?

Re: Edit exported word document
Spoo - Tue Oct 20 14:30:16 EDT 2015

Hi,

 

I have used your script for automating the export to word. For my requirement, i need to export some portion of the module in Book format and another portion of the module in Table format ti Word. I am facing issue in appending the table format to the first doument. Can you please help me export the same module from doors, into book and Table format in a single word doc?